import {RouteRecordRaw} from 'vue-router';

import RouteLayout from '@/views/layout/RouteLayout.vue';
import MainLayout from '@/views/layout/MainLayout.vue';
import LoginLayout from '@/views/layout/LoginLayout.vue';

// 路由配置
export const routeConfigs: Array<RouteRecordRaw> = [
    {
        path: '/',
        component: LoginLayout
    },

    {
        path: '/auth',
        component: LoginLayout,
        children: [
            {
                path: 'login',
                name: 'LoginView',
                component: () => import('../views/login/LoginView.vue'),
                meta: {
                    title: '登录'
                }
            },
            {
                path: 'register',
                name: 'RegisterView',
                component: () => import('../views/login/RegisterView.vue'),
                meta: {
                    title: '注册'
                }
            }
        ]
    },

    {
        path: '/',
        component: MainLayout,
        meta: {
            // 标记此路由为菜单的根路由，其子路由会被解析为菜单
            isRootMenu: true
        },
        children: [
            // 首页
            {
                path: 'home',
                name: 'Home',
                component: () => import('../views/home/Home.vue'),
                meta: {
                    title: '首页',
                    icon: 'vxe-icon-custom-column',
                    isMenu: true
                }
            },

            // 流程管理
            {
                path: 'processManager',
                name: 'ProcessManager',
                component: () => import('../views/process/ProcessManager.vue'),
                meta: {
                    title: '流程管理',
                    icon: 'vxe-icon-num-list',
                    isMenu: true
                }
            },

            // 定时任务
            {
                path: 'xxl-job-manager',
                name: 'XxlJobManager',
                component: () => import('../views/job/XxlJobManager.vue'),
                meta: {
                    title: '定时任务',
                    icon: 'vxe-icon-menu',
                    isMenu: true
                }
            },

            // 用户管理
            {
                path: 'user-info-manager',
                name: 'UserInfoManager',
                component: () => import('../views/user/UserInfoManager.vue'),
                meta: {
                    title: '用户信息',
                    icon: 'vxe-icon-user',
                    isMenu: true
                }
            },


            // 机构管理
            {
                path: 'company-info-manager',
                name: 'CompanyInfoManager',
                component: () => import('../views/company/CompanyInfoManager.vue'),
                meta: {
                    title: '机构管理',
                    icon: 'vxe-icon-flow-branch',
                    isMenu: true
                }
            },

            // 系统管理
            {
                path: 'system',
                component: RouteLayout,
                name: 'System',
                meta: {
                    title: '系统管理',
                    icon: 'vxe-icon-setting',
                    isMenu: true
                },
                children: [
                    {
                        path: 'system-role-manager',
                        name: 'SystemRoleManager',
                        component: () => import('../views/system/SystemRoleManager.vue'),
                        meta: {
                            title: '角色管理',
                            isMenu: true
                        }
                    },
                    {
                        path: 'system-router-manager',
                        name: 'SystemRouterManager',
                        component: () => import('../views/system/SystemRouteManager.vue'),
                        meta: {
                            title: '路由管理',
                            isMenu: false
                        }
                    },
                    {
                        path: 'system-request-log',
                        name: 'SystemRequestLog',
                        component: () => import('../views/system/SystemRequestLog.vue'),
                        meta: {
                            title: '用户日志',
                            isMenu: true
                        }
                    }
                ]
            },
        ]
    },

    // 404 页面
    {
        path: '/404',
        name: 'PageError404',
        component: () => import('../views/error/PageError404.vue'),
        meta: {
            title: '404 找不到页面'
        }
    },

    // 403 页面
    {
        path: '/403',
        name: 'PageError403',
        component: () => import('../views/error/PageError403.vue'),
        meta: {
            title: '403 无权限访问'
        }
    },

    // 其他未匹配的页面重定向到 404 页面
    {
        path: '/:pathMatch(.*)*',
        redirect: {
            name: 'PageError404'
        }
    }
];
